<?php
/***********************************************************************
 * @package     IvanEngine
 * @subpackage  Framework
 * @author      Ivan <ivanzx@msn.com>
 * @created     2010-07-20
 ***********************************************************************/
if(defined("IVANENGINE_FRAMEWORK_ROUTING_DEFAULT"))
    die("Redefinition macro in :".__FILE__."(".__LINE__.")");
define("IVANENGINE_FRAMEWORK_ROUTING_DEFAULT", true);

require_once (dirname(__FILE__).'/../Common.php');
require_once (M_CORE_PATH.'Routing/Routing.php');

class CDefaultRouting extends CRouting
{
    public function __construct()
    {
        parent::__construct();
    }

    public function __destruct()
    {
        parent::__destruct();
    }
    
    public function GetCurUri()
    {
        $parameters = $_GET;
        $action = sprintf('%s/%s', $parameters['plugin'], $parameters['action']);

        // other parameters
        unset($parameters['plugin'], $parameters['action']);
        ksort($parameters);
        $parameters = count($parameters) ? '?'.http_build_query($parameters, null, '&') : '';

        return sprintf('%s%s', $action, $parameters);
    }
    
    public function Generate($route, $parameters, $absolute)
    {
        $parameters = http_build_query($parameters, null, '&');

        return $this->_FixUrl(($parameters ? '?'.$parameters : ''), $absolute);
    }
}
?>
